﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Ex04.Menus.Test
{
    using Ex04.Menus.Interfaces;

    public class Examples
    {
        public class HappyBirthday : IAction
        {
            public void DoIt()
            {
                string message =
@"                   dMP dMP  .aMMMb   dMMMMb   dMMMMb   dMP dMP
                  dMP dMP  dMP dMP  dMP.dMP  dMP.dMP  dMP.dMP
                 dMMMMMP  dMMMMMP  dMMMMP   dMMMMP    VMMMMP
                dMP dMP  dMP dMP  dMP      dMP      dA .dMP
               dMP dMP  dMP dMP  dMP      dMP       VMMMP

      dMMMMb   dMP  dMMMMb  dMMMMMMP  dMP dMP  dMMMMb  .aMMMb   dMP dMP
     dMP dMP  amr  dMP.dMP    dMP    dMP dMP  dMP VMP  dMP dMP  dMP.dMP
    dMMMMK   dMP  dMMMMK     dMP    dMMMMMP  dMP dMP  dMMMMMP   VMMMMP
   dMP.aMF  dMP  dMP AMF    dMP    dMP dMP  dMP.aMP  dMP dMP  dA .dMP
  dMMMMP   dMP  dMP dMP    dMP    dMP dMP  dMMMMP   dMP dMP   VMMMP";
                
                Console.WriteLine(message);
            }
        }

        public class Paradox : IAction
        {
            public void DoIt()
            {
                string message =
@"
         _________________________.
        / _____________________  /|
       / / ___________________/ / |
      / / /| |               / /  |
     / / / | |              / / . |
    / / /| | |             / / /| |
   / / / | | |            / / / | |
  / / /  | | |           / / /| | |
 / /_/___| | |__________/ / / | | |
/________| | |___________/ /  | | |
| _______| | |__________ | |  | | |
| | |    | | |_________| | |__| | |
| | |    | |___________| | |____| |
| | |   / / ___________| | |_  / /
| | |  / / /           | | |/ / /
| | | / / /            | | | / /
| | |/ / /             | | |/ /
| | | / /              | | ' /
| | |/_/_______________| |  /
| |____________________| | /
|________________________|/

";
                
                Console.WriteLine(message);
            }
        }

        public class Monkey : IAction
        {
            public void DoIt()
            {
                string message =
@"
       .--.  .-'''-.  .--.
      /."".v'.-. .-.`v.""\\
      ||  / / O| | O\ \  ||
      \\_/| \__| |__/  \_//
       `-'\  .-n-n-.  /`-'
        _.-\/       \/-._
      .'   (\`.___.'/)   `.
     /      \`.___.'/      `.
    /        `.___.'         \
    |     |             \     \
    |     |   .      .  |\     \
    |     |             | \     \
     \     \            |  \     \
      \     \           |.' `.    \
       `.    \         .'     `.   \
  _.._   `.   `-. ___ /        /`.  `.
.'    `-._ `.    `.__)       .'  /    `.
|         `-.\     \/      .'   / /\  )|\.
 \          _/ / /|/     .'    (_/ / / | \)
  `._      (__/_/-/   ..'         (_/| |\_)
     ``--._____.-(     `.            `-'
                  `--.   `.
                    (_/\ \\\
                       /_///
";
                
                Console.WriteLine(message);
            }
        }

        public class Factorial : IAction
        {
            public void DoIt()
            {
                double inputNumber = getDoubleFromUser();
                double outputNumber = factorialHelper(inputNumber);

                Console.WriteLine("{0}! == {1}", inputNumber, outputNumber);
            }

            private double factorialHelper(double n)
            {
                double retVal;

                if (n == 0)
                {
                    retVal = 1;
                }
                else
                {
                    retVal = n * factorialHelper(n - 1);
                }

                return retVal;
            }
        }

        public class Sin : IAction
        {
            public void DoIt()
            {
                double inputNumber = getDoubleFromUser();

                Console.WriteLine("Sin({0}) == {1}", inputNumber, System.Math.Sin(inputNumber));
            }
        }

        public class Cos : IAction
        {
            public void DoIt()
            {
                double inputNumber = getDoubleFromUser();

                Console.WriteLine("Cos({0}) == {1}", inputNumber, System.Math.Cos(inputNumber));
            }
        }

        public class SquareRoot : IAction
        {
            public void DoIt()
            {
                double inputNumber = getDoubleFromUser();

                Console.WriteLine("{0}^0.5 == {1}", inputNumber, System.Math.Sqrt(inputNumber));
            }
        }

        private static double getDoubleFromUser()
        {
            Console.WriteLine("Enter a number please:");
            string inputStr = Console.ReadLine();
            double inputNumber;

            while (!double.TryParse(inputStr, out inputNumber))
            {
                Console.WriteLine("Enter a proper number please:");
                inputStr = Console.ReadLine();
            }

            return inputNumber;
        }
    }
}
